package com.lanxiao.cloud.modules.dict.application.listener;

import com.google.common.eventbus.Subscribe;
import com.lanxiao.cloud.common.redis.template.RedisTemplateUtils;
import com.lanxiao.cloud.modules.dict.domain.event.DictChangeEvent;
import com.lanxiao.cloud.modules.dict.domain.event.DictChangePublisher;
import com.lanxiao.cloud.modules.dict.infrastructure.constant.DictRedisConstant;
import org.springframework.stereotype.Component;

/**
 * @author ：qiaoliang
 * @date ：2021-09-26
 */
@Component
public class DictChangeListener {

  public DictChangeListener(DictChangePublisher publisher) {
    publisher.register(this);
  }

  @Subscribe
  public void changeEvent(DictChangeEvent event){
    RedisTemplateUtils.delete(DictRedisConstant.DICT_DATA);
  }

}
